limsSample.choosePage = {

    getGridParam : function() {
        var _this = this, columns = limsSample.getChooseListColumns();
        _this.param.single ? columns.unshift({
            radio : true
        }) : columns.unshift({
            checkbox : true
        });
        return {
            type : 'grid',
            id : 'lims-sample-choose-list-grid',
            url : limsSample.baseUrl + '/queries/rows',
            requestData : _this.param,
            page : true,
            filterOpen : true,
            columns : columns,
            toolbar : [ {
                type : 'button',
                text : 'GIKAM.BUTTON.CONFIRM',
                icon : 'select',
                onClick : function() {
                    Gikam.getLastModal().close(Gikam.getComp('lims-sample-choose-list-grid').getSelections());
                }
            },{
                type : 'button',
                text : 'GIKAM.TITLE.CHOOSE.SEARCH',
                icon : 'select',
                onClick : function () {
                    Gikam.create('modal',{
                        title : 'GIKAM.TITLE.CHOOSE.SEARCH',
                        height : 400,
                        width : 400,
                        url : limsSample.baseUrl + '/page/sample-select'+Gikam.param({
                            type : 'sample'
                        }),
                        onAfterClose : function (data) {
                            if (Gikam.isEmpty(data)){
                                return;
                            }
                            let items = data.sampleCode.replace(/[(\r\n)|(\ +)|(，)|(；)|(;)]/g,',');
                            let param = _this.param;
                            param.sampleCode_IN = items;
                            Gikam.post(limsSample.baseUrl + '/queries/rows',Gikam.getJsonWrapper({
                                f : param
                            })).done(function (data) {
                                Gikam.getComp('lims-sample-choose-list-grid').loadData(data.rows);
                            })
                        }
                    })
                }
            }]
        }
    },

    create : function() {
        var _this = this;
        Gikam.create('layout', {
            id : 'lims-sample-choose-list-layout',
            renderTo : Gikam.getLastModal().window.$dom,
            center : {
                items : [ this.getGridParam() ]
            }
        });
    },

    init : function(param) {
        this.param = param;
        this.create();
    }
};
